import service from "..";

interface KeyType{
    account:string, 
    name: string, 
    phone: string
}

export const getAllUserList = () => {
    return service({
        url: '/user/all',
        method: 'get',
    })
}

export const getUserList = (params: any) => {
    return service({
        url: '/user/list',
        method: 'get',
        params
    })
}

export const searchUser = ( params:{ keywords: KeyType; current?: number; pageSize?: number} ) => {
        return service({
            url: '/user/search',
            method: 'get',
            params
        })
}

export const selectedOrganization = ( params:{ keywords: string; current?: number; pageSize?: number} ) => {
        return service({
            url: '/user/selected',
            method: 'get',
            params
        })
}

export const selectedStatus = ( params:{ keywords: boolean; current?: number; pageSize?: number} ) => {
        return service({
            url: '/user/status',
            method: 'get',
            params
        })
}

export const switchStatus = ( status: boolean ) => {
    return service({
        url: '/user/switch',
        method: 'post',
        data: { status }
    })
}

export const addUser = (data: any) => {
    return service({
        url: '/user/add',
        method: 'post',
        data
    })
}

export const updateUser = (data: any) => {
    return service({
        url: '/user/update',
        method: 'post',
        data
    })
}

export const deleteUser = (id: number) => {
    return service({
        url: '/user/delete',
        method: 'post',
        params: { id }
    })
}